package cn.com.cetccst.mdm.engine;

import android.app.Activity;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.Intent;

public class DQTMdmEngine extends HWMdmEngine {
    public DQTMdmEngine(Context context) {
        super(context);
    }

    @Override
    public boolean isActiveDeviceAdmin() {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        return devicePolicyManager.isAdminActive(adminComponent);
    }

    @Override
    public boolean setActiveDeviceAdmin(Activity activity) {
        Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, adminComponent);
        //intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.add_admin_extra_app_text));
        activity.startActivityForResult(intent, 10000);
        return true;
    }

    @Override
    public boolean removeDeviceAdmin() {
        DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
        devicePolicyManager.removeActiveAdmin(adminComponent);
        return true;
    }

    @Override
    public String getName() {
        return "hw";
    }
}
